package com.timemanage.activity

import android.os.Bundle
import android.view.View
import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.timemanage.R
import com.timemanage.activity.ui.home.HomeFragment
import com.timemanage.databinding.ActivityBottomBarBinding





class BottomBar : AppCompatActivity() {

    private lateinit var binding: ActivityBottomBarBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)


        //---------bottomBar---------------------------------------------
        binding = ActivityBottomBarBinding.inflate(layoutInflater)
        setContentView(binding.root)
        val navView: BottomNavigationView = binding.navView

        val navController = findNavController(R.id.nav_host_fragment_activity_bottom_bar)
        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.

        val id = intent.getIntExtra("id", 0)
        if (id == 1) {
            supportFragmentManager
                .beginTransaction()
                .replace(R.id.navigation_home,HomeFragment())
                .addToBackStack(null)
                .commit()
        }
        val appBarConfiguration = AppBarConfiguration(
            setOf(
                R.id.navigation_home, R.id.navigation_notifications, R.id.navigation_dashboard,R.id.mineragment
            )
        )
        setupActionBarWithNavController(navController, appBarConfiguration)
        navView.setupWithNavController(navController)
    }
}